package com.inspur.neoinput.neo4j.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.inspur.neoinput.neo4j.entity.NormalizeTerm;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Mr.wang
 * @since 2021-03-04
 */
@Repository
@Mapper
public interface NormalizeTermMapper extends BaseMapper<NormalizeTerm> {

    @Select("SELECT\n" +
            "\t        ntm.normalize_term_cn normalizeTermCn,\n" +
            "\t        et.entity_type_name_cn entityTypeNameCn\n" +
            "        FROM\n" +
            "\t        normalize_term ntm\n" +
            "\t    LEFT JOIN normalize_term_type_rel nttl ON ntm.normalize_term_id = nttl.normalize_term_id\n" +
            "\t    LEFT JOIN entity_type et on nttl.entity_type_id = et.entity_type_id\n" +
            "        WHERE\n" +
            "\t        ntm.STATUS = '1'")
    List<Map<String,String>> getNodeAndLable();

    @Select("SELECT\n" +
            "\ter.entity_word1_name entityWord1Name,\n" +
            "\tetr.entity_type1_name entityType1Name,\n" +
            "\ter.entity_word2_name entityWord2Name,\n" +
            "\tetr.entity_type2_name entityType2Name,\n" +
            "\ter.rel_group_id relGroupId,\n" +
            "\tetr.`desc`\n" +
            "FROM\n" +
            "\tentity_rel er\n" +
            "\tLEFT JOIN entity_type_rel etr ON etr.entity_type_rel_code = er.entity_type_rel_code \n" +
            "WHERE\n" +
            "\ter.STATUS = '1'")
    List<Map<String,String>> getTypeAndRel();

    @Select("select rel_group_id relGroupId from entity_rel where rel_group_id != 0")
    List<String> getGroupId();
}
